package com.dyh.quickdemozwei.aspect;


import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Slf4j
@Aspect //声明切面
@Component //让spring容器管理
public class LogSpeedAspect {



    @Around("@annotation(com.dyh.quickdemozwei.anno.LogSe1)")
    public Object around(ProceedingJoinPoint pjp) throws Throwable {




        String method =    pjp.getTarget().getClass()+"."+ pjp.getSignature().getName();

        log.info(">>>>>>>>开始执行Se1{}", method);

        // 记录开始时间
        long begin = System.currentTimeMillis();

        // 执行目标 service
        Object result = pjp.proceed();

        // 记录结束时间
        long end = System.currentTimeMillis();
        long takeTime = end - begin;

        log.info("<<<<<<<<{} 执行结束Se1，耗时：{} 毫秒",method,takeTime);

        return result;

    }



}
